package org.deadline.service.user;

import java.util.List;
import org.deadline.model.user.UserMailMessage;
import org.deadline.repository.user.UserMailMessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class UserMailMessageServiceImpl implements UserMailMessageService {

	@Autowired
    UserMailMessageRepository userMailMessageRepository;

	public long countAllUserMailMessages() {
        return userMailMessageRepository.count();
    }

	public void deleteUserMailMessage(UserMailMessage userMailMessage) {
        userMailMessageRepository.delete(userMailMessage);
    }

	public UserMailMessage findUserMailMessage(Long id) {
        return userMailMessageRepository.findOne(id);
    }

	public List<UserMailMessage> findAllUserMailMessages() {
        return userMailMessageRepository.findAll();
    }

	public List<UserMailMessage> findUserMailMessageEntries(int firstResult, int maxResults) {
        return userMailMessageRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveUserMailMessage(UserMailMessage userMailMessage) {
        userMailMessageRepository.save(userMailMessage);
    }

	public UserMailMessage updateUserMailMessage(UserMailMessage userMailMessage) {
        return userMailMessageRepository.save(userMailMessage);
    }
}
